#include "Utilities.hh"
#include <random>
#include <ctime>
#include <iomanip>
#include <sstream>
#include <limits>

namespace Utilities {
    std::string generateRandomDigits(int length) {
        static std::random_device rd;
        static std::mt19937 gen(rd());
        static std::uniform_int_distribution<> dis(0, 9);

        std::stringstream ss;
        for (int i = 0; i < length; ++i) {
            ss << dis(gen);
        }
        return ss.str();
    }

    std::string getCurrentDateString() {
        std::time_t now = std::time(nullptr);
        std::tm* now_tm = std::localtime(&now);
        
        std::stringstream ss;
        ss << std::put_time(now_tm, "%Y-%m-%d");
        return ss.str();
    }

    std::string formatCurrency(double amount) {
        std::stringstream ss;
        ss << "¥" << std::fixed << std::setprecision(2) << amount;
        return ss.str();
    }

    void clearScreen() {
        #ifdef _WIN32
            system("cls");
        #else
            system("clear");
        #endif
    }

    void pressEnterToContinue() {
        std::cout << "\nPress Enter to continue...";
        std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
        std::cin.get();
    }
}